//
//  SixModulesInterfaceView.m
//  LoveTrail
//
//  Created by giantumbrella on 15/6/27.
//  Copyright (c) 2015年 赵娟. All rights reserved.
//

#import "SixModulesInterfaceView.h"
#import "CommonMacro.h"

@interface SixModulesInterfaceView ()
@property (nonatomic,strong) UIButton *togatherButton;
@property (nonatomic,strong) UIButton *panicBuyButton;

@end
@implementation SixModulesInterfaceView

- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self createSubview];
    }
    return self;
}

- (void)createSubview
{

    CGFloat imageViewX = 0;
    CGFloat imageViewY = 2;
    CGFloat imageViewW = SCREEN_WIDTH/2;
    CGFloat imageViewH = 150;
    CGFloat togthBuyH = 100;
    CGFloat togthBuyY = imageViewH+imageViewY;
    CGFloat brandY = togthBuyH+togthBuyY;
    //热卖
    UIButton *leftButton = [[UIButton alloc] initWithFrame:CGRectMake(imageViewX, imageViewY, imageViewW, imageViewH)];
    //        leftButton.backgroundColor = [UIColor redColor];
    [leftButton setBackgroundImage:[UIImage imageNamed:@"热卖"] forState:UIControlStateNormal];
    leftButton.tag = 1000;
    [self addSubview:leftButton];
    [leftButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];

    
    //新品上市
    UIButton *rightTopButton = [[UIButton alloc] initWithFrame:CGRectMake(imageViewW, imageViewY, imageViewW, imageViewH/2)];
    rightTopButton.backgroundColor = [UIColor purpleColor];
    [rightTopButton setBackgroundImage:[UIImage imageNamed:@"新品上架"] forState:UIControlStateNormal];
    rightTopButton.tag = 1001;
    [self addSubview:rightTopButton];
    [rightTopButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    
    //限时折扣
    UIButton *rightButtomButton = [[UIButton alloc] initWithFrame:CGRectMake(imageViewW, imageViewH/2, imageViewW, imageViewH/2)];
    rightButtomButton.backgroundColor = [UIColor cyanColor];
    [rightButtomButton setBackgroundImage:[UIImage imageNamed:@"限时折扣"] forState:UIControlStateNormal];
    rightTopButton.tag = 1002;
    [self addSubview:rightButtomButton];
    [rightButtomButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    
    //团购
    self.togatherButton = [[UIButton alloc] initWithFrame:CGRectMake(imageViewX,togthBuyY, imageViewW, togthBuyH)];
    [self.togatherButton setBackgroundImage:[UIImage imageNamed:@"团购"] forState:UIControlStateNormal];
    self.togatherButton.tag = 1003;
    [self addSubview:self.togatherButton];
    [self.togatherButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    //抢购
    self.panicBuyButton = [[UIButton alloc] initWithFrame:CGRectMake(imageViewW, togthBuyY, imageViewW, togthBuyH)];
    [self.panicBuyButton setBackgroundImage:[UIImage imageNamed:@"抢购"] forState:UIControlStateNormal];
    self.panicBuyButton.tag = 1004;
    [self addSubview:self.panicBuyButton];
    [self.panicBuyButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];

    //品牌
    UIButton *brandButton = [[UIButton alloc] initWithFrame:CGRectMake(imageViewX, brandY, SCREEN_WIDTH*0.33, togthBuyH)];
    [brandButton setBackgroundImage:[UIImage imageNamed:@"大牌专区"] forState:UIControlStateNormal];
    [self addSubview:brandButton];
    brandButton.tag = 1005;
    [brandButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    
    //优生优育资讯频道
    UIButton *channelButton = [[UIButton alloc] initWithFrame:CGRectMake(brandButton.frame.size.width, brandY, SCREEN_WIDTH*0.34, togthBuyH)];
    [channelButton setBackgroundImage:[UIImage imageNamed:@"优生优育资讯频道"] forState:UIControlStateNormal];
    [self addSubview:channelButton];
    channelButton.tag = 1006;
    [channelButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    
    //俱乐部
    UIButton *clubButton = [[UIButton alloc] initWithFrame:CGRectMake(channelButton.frame.size.width+channelButton.frame.origin.x, brandY, SCREEN_WIDTH*0.33, togthBuyH)];
    [clubButton setBackgroundImage:[UIImage imageNamed:@"俱乐部"] forState:UIControlStateNormal];
    clubButton.tag =1007;
    [clubButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:clubButton];
}

- (void)buttonClick:(UIButton *)button
{
    if ([self.sixButtonDelegate respondsToSelector:@selector(clickSixDifferentButton:)]) {
        [self.sixButtonDelegate clickSixDifferentButton:button];
    }
}
@end
